#ifndef __UM_UFD_H__
#define __UM_UFD_H__

#include "um_basic_types.h"
#include "umapi_os_list.h"
#include "umapi_socket.h"


typedef struct
{
	UM_HANDLE fd;
	UM_S32 (*conntect)(UM_HANDLE fd, UM_VOID* param,UM_VOID *efd);
	UM_S32 (*read)(UM_HANDLE fd, UM_VOID* param);
	UM_S32 (*write)(UM_HANDLE fd, UM_VOID* param);
	UM_S32 (*disconnect)(UM_HANDLE fd, UM_VOID* param);
	UM_S32 (*isReading)(UM_HANDLE fd);
	UM_VOID (*setReadFlag)(UM_HANDLE fd, UM_BOOL bl);
	UM_S32 status;
	UM_S32 reading;
	UM_U32 lasttick;
	UM_U32 connecttick;
	UM_U64 readCount;
	UM_U64 sendCount;
	UM_HANDLE mutex;
	UM_BOOL active;
	UM_VOID *pri;
	UM_VOID *pri1;
	UMAPI_SOCKET_ADDR ipaddr;
	UMAPI_SOCKET_ADDR localaddr;
	struct umapi_list_head head;
}UM_EFD;

UM_VOID um_ufd_setWriteFunction(UM_HANDLE fd, 
	UM_S32 (*write)(UM_HANDLE fd, UM_VOID* param),
	UM_VOID *param);

UM_EFD* um_ufd_malloc(UM_HANDLE fd,
	UM_S32 (*conntect)(UM_HANDLE fd, UM_VOID* param,UM_VOID *efd),
	UM_S32 (*read)(UM_HANDLE fd, UM_VOID* param),
	UM_S32 (*disconnect)(UM_HANDLE fd, UM_VOID* param),
	UM_U32 status,
	UM_VOID *pri);
UM_VOID um_ufd_free(UM_VOID **pfd);

extern UM_VOID um_ufd_init();

static 	inline UM_S32 getReadFlag(UM_HANDLE fd)
{
	UM_S32 r = 0;
	UM_EFD * p =(UM_EFD *)fd;
	r = p->reading;
	return r;
}
static inline UM_VOID setReadFlag(UM_HANDLE fd, UM_BOOL bl)
{
	UM_EFD * p =(UM_EFD *)fd;
	p->reading = bl;
	return ;
}

#endif

